#include <zenilib.h>
#include "Effect.h"
#include "Globals.h"

using namespace std;

Effect::Effect(Vector2 pos_, Vector2 scale_) :
	GameObject(pos_, scale_),
	timeSinceChange(0),
	frameNum(0)
{
}

void Effect::update(const float & timestep)
{
	timeSinceChange += timestep;
	if (timeSinceChange > frameDelta){
		timeSinceChange = 0;
		frameNum++;
		if (!finished()){
			textures[0] = frames[frameNum];
		}
	}
	GameObject::update(timestep);
}

BloodEffect::BloodEffect(Vector2 pos_) :
	Effect(pos_, Vector2(50, 50))
{
	for (int i = 1; i <= 4; i++){
		frames.push_back("Blood" + itos(i));
	}
	frameDelta = 0.05f;
	addTexture(frames[0]);
	//playSound("Hit");
}

ExplosionEffect::ExplosionEffect(Vector2 pos_) : 
	Effect(pos_, Vector2(150, 150))
{
	for (int i = 1; i <= 6; i++){
		frames.push_back("Explosion" + itos(i));
	}
	frameDelta = 0.1f;
	addTexture(frames[0]);
	//playSound("Explode");
}